package com.losl.common.util;

import cn.hutool.extra.servlet.ServletUtil;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

public class ServletUtils extends ServletUtil {
    public static HttpServletRequest getRequest(){
        HttpServletRequest request=null;
        try {
            ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
            if (!StringUtils.isNull(requestAttributes)){
                request = requestAttributes.getRequest();
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return request;
    }

}
